package com.zhenyi.youqu.miniapp;

import java.util.List;

import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.SqlPara;
import com.youqu.common.model.YqApp;
import com.youqu.common.model.YqModel;
import com.youqu.common.model.YqModelInfo;
import com.zhenyi.youqu.core.YQMiniAppController;

/**
 * 自定义模组模块
 * 
 * @author cen
 *
 */
public class ModelController extends YQMiniAppController {

	/**
	 * 当前平台
	 * 
	 * @return
	 */
	protected int getPlatorm() {
		return 1;
	}

	/**
	 * 模块内容列表
	 */
	@Override
	public void list() {
		Long modelId = getParaToLong("modelId");
	}

	/**
	 * 活动模块
	 */
	@Override
	public void index() {
		Long modelId = getParaToLong("modelId");
		// 先找到model
		// 再根据count找到一定数量展示的内容
		YqModel model = YqModel.dao.findById(modelId);
		if (model == null) {
			renderError(404);
			return;
		}
		Kv kv = Kv.create();
		kv.set("modelId", modelId);
		YqApp app = getApp();
		kv.set("appId", app.getId());
		SqlPara sqlPara = db.getSqlPara("YQModelInfoList", kv);
		List<YqModelInfo> list = YqModelInfo.dao.paginate(1, model.getShowCount(), sqlPara).getList();
		model.put("list", list);
		renderResult(model);
	}

}
